package starfire.gui.siteTree;

import java.util.Iterator;
import javax.swing.tree.*;
import starfire.ftp.FtpFile;
/**
 * <p>Title: JFtp</p>
 * <p>Description: ftp client</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author starfire
 * @version 1.0
 */

public   class FtpFileNode extends DefaultMutableTreeNode
  {
    FtpFile ff = null;
    public FtpFileNode(FtpFile ff)
    {
      super(ff);
      this.ff = ff;
      if (ff.isDirectory())
        this.setAllowsChildren(true);
      else
        this.setAllowsChildren(false);
    }

    public boolean getAllowsChildren()
    {
      return ff.isDirectory();
    }

    public boolean isLeaf()
    {
      return ff.isFile();
    }

    public FtpFile getFtpFile()
    {
      return ff;
    }

    public void explore()
    {
      this.removeAllChildren();
      Iterator iterator = ff.childrenIterator();
      while (iterator.hasNext())
      {
        this.add(new FtpFileNode((FtpFile)iterator.next()));
      }
    }

    public String toString()
    {
      return ff.getName();
    }
  }
